package gientech.spring.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import gientech.spring.demo.dto.UserChangeEvent;
import gientech.spring.demo.entity.User;
import gientech.spring.demo.mapper.UserMapper;

import gientech.spring.demo.service.UserService;

import gientech.spring.demo.util.BloomFilterUtil;

import gientech.spring.demo.util.UserMessageProducer;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.redisson.client.codec.StringCodec;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;


@Service
@CacheConfig(cacheNames = "user")
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService {

    @Autowired
    private UserMessageProducer userMessageProducer;

    @Autowired
    private UserMapper userMapper;

    @Override
    public void addUser(UserChangeEvent userChangeEvent) {

        userMessageProducer.sendUserChangeEvent(userChangeEvent);
    }

    @Override
    @Transactional(isolation = Isolation.SERIALIZABLE)
    public void doupdateUser(UserChangeEvent userChangeEvent) {

        userMapper.updateById(userChangeEvent.getUId(), userChangeEvent.getUUsername());
        userMapper.addTx(userChangeEvent.getTxNo());

    }




}




